package com.hopedove.yieldmanage.net;

import android.os.Handler;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.hopedove.yieldmanage.entity.ProductEntity;

import org.json.JSONObject;

public class RequestServiceImpl {






    /**
     *坯布 登陆接口
     *
     * @param handler
     * @param requestType
     */
    public static void bang_login(Handler handler, int requestType, String YHBH,String password) {

        JSONObject inputInfo = new JSONObject();

        try {
//"JY142"
            inputInfo.put("YHM", YHBH);
            inputInfo.put("YHKL", password);

        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "login";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }


    /**
     * 页面初始化统计当日匹数与重量
     * @param handler
     * @param requestType
     */
    public static void getInitInfo(Handler handler,int requestType, String userBean) {

        JSONObject inputInfo = new JSONObject();

        try {
            JSONObject jsonObject=new JSONObject(userBean);
            inputInfo.put("userBean", jsonObject);


        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName="TickettoinitApp" ;

        IServiceImpl.callWebMethod(handler, requestType, inputInfo , methodName);
    }



    /**
     * 根据三联单号带出数据
     * @param handler
     * @param requestType
     * @param clothTktNo
     */
    public static void getProductInfo(Handler handler,int requestType, String clothTktNo) {


        JSONObject inputInfo = new JSONObject();

        try {

            inputInfo.put("CLOTHTKTNO", clothTktNo);


        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName="TicketfetchDataApp" ;

        IServiceImpl.callWebMethod(handler, requestType, inputInfo , methodName);
    }






    /**
     * 判断胚布是否已经称重
     * @param handler
     * @param requestType
     * @param clothTktNo
     */
    public static void getIsStandard(Handler handler,int requestType, String clothTktNo) {


        JSONObject inputInfo = new JSONObject();

        try {

            inputInfo.put("CLOTHTKTNO", clothTktNo);


        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName="TicketisStandardApp" ;

        IServiceImpl.callWebMethod(handler, requestType, inputInfo , methodName);
    }






    /**
     * 判断三联单号是否已扫描
     * @param handler
     * @param requestType
     * @param clothTktNo
     */
//    public static void getIsExists(Handler handler,int requestType, String clothTktNo) {
//
//
//        JSONObject inputInfo = new JSONObject();
//
//        try {
//
//            inputInfo.put("CLOTHTKTNO", clothTktNo);
//
//
//        } catch (Exception e) {
//            // TODO: handle exception
//        }
//        String methodName="TicketisExistsApp" ;
//
//        IServiceImpl.callWebMethod(handler, requestType, inputInfo , methodName);
//    }


    /**
     * 新增坯布称重信息
     * @param handler
     * @param requestType
     * @param product
     */
    public static void addProduct(Handler handler,int requestType , String userBean, ProductEntity product) {


        JSONObject inputInfo = new JSONObject();

        try {

            JSONObject jsonObjectUserBean=new JSONObject(userBean);
            inputInfo.put("userBean", jsonObjectUserBean);
            Gson gson = new GsonBuilder().serializeNulls().create();
            JSONObject jsonObjectProduct=new JSONObject(gson.toJson(product));
            inputInfo.put("jsonData", jsonObjectProduct);

        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName="TicketeditApp" ;

        IServiceImpl.callWebMethod(handler, requestType, inputInfo , methodName);
    }

    /**
     * 页面初始化统计当日匹数与重量
     * @param handler
     * @param requestType
     */
    public static void getBanList(Handler handler,int requestType, String userBean) {

        JSONObject inputInfo = new JSONObject();

        try {
            JSONObject jsonObject=new JSONObject(userBean);
            inputInfo.put("userBean", jsonObject);


        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "TickettoListApp";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }

    /**
     * 获取系统时间
     *
     * @param handler
     * @param requestType
     */
    public static void jy_getsysdate(Handler handler, int requestType) {


        String methodName = "getSysdate";

        IServiceImpl.callWebMethod(handler, requestType, "", methodName);
    }

    public static void zz_getchejian(Handler handler, int requestType) {

        String methodName = "toQueryWorkShop";

        IServiceImpl.callWebMethod(handler, requestType, "", methodName);
    }

    /**
     * 检验 织造查询
     *
     * @param handler
     * @param requestType
     */
    public static void zz_query(Handler handler, int requestType, String WORKSHOP, String LISTDATE_FROM, String LISTDATE_TO, String CLOTHTKTNO, String MACHINENO_FROM, String MACHINENO_TO) {

        JSONObject inputInfo = new JSONObject();

        try {

            inputInfo.put("WORKSHOP", WORKSHOP);
            inputInfo.put("LISTDATE_FROM", LISTDATE_FROM);
            inputInfo.put("LISTDATE_TO", LISTDATE_TO);
            inputInfo.put("CLOTHTKTNO", CLOTHTKTNO);
            inputInfo.put("MACHINENO_FROM", MACHINENO_FROM);
            inputInfo.put("MACHINENO_TO", MACHINENO_TO);

        } catch (Exception e) {
            // TODO: handle exception
        }
        String methodName = "longFaultList";

        IServiceImpl.callWebMethod(handler, requestType, inputInfo, methodName);
    }
}
